package netty.fry;

import net.dreamlu.iot.mqtt.core.client.MqttClient;

import java.nio.ByteBuffer;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @Author zhangtao
 * @create 2021/12/27 13:36
 */
public class HennyPennyFry {
    public static void main(String[] args) {
        String COOK_START = "";

        String QUANTITY = "";

        String TEMPERATURE = "";

        String COOK_DONE = "";

        // 初始化 mqtt 客户端
        MqttClient client = MqttClient.create()
                .ip("127.0.0.1")
                .port(1883)
                .connect();

        ScheduledExecutorService schedule = Executors.newScheduledThreadPool(4);
        schedule.scheduleAtFixedRate(
                new

                        Runnable() {
                            @Override
                            public void run() {
                                client.publish("/us/qpm/server/workflow", ByteBuffer.wrap(COOK_START.getBytes()));
                                client.publish("/us/qpm/server/workflow", ByteBuffer.wrap(QUANTITY.getBytes()));
                                client.publish("/us/qpm/server/environmental", ByteBuffer.wrap(TEMPERATURE.getBytes()));
                                client.publish("/us/qpm/server/workflow", ByteBuffer.wrap(COOK_DONE.getBytes()));
                            }
                        }, 5, 60 * 60, TimeUnit.SECONDS);
    }
}
